/**
 * @author
 */
$(document).ready(function(){
    $("#authForm").submit(function(){
        var username = $("#authUsername").val();
        var password = $("#authPassword").val();
        $.post(
				("ajax/auth.php?rand=" + Math.random()),
				{
                    username: username,
					password: password
                },
				function(data){
					if (data >= 0) {
						document.location.href = "index.php";
					} else {
                        $("#errorMessage").text("Неверный логин/пароль").show().fadeOut(3000);
                    }
				},
				"text"
		);
        return false;
    });    
});
function authorization()
{
		
$("#authDiv").dialog({
		buttons: {
			"Вход": function(){
				$('#authForm').submit();
        	},
			"Отмена": function(){
				$(this).dialog("close")
			}
		},
		modal: true,
		draggable : false
	}).dialog("open");
}
function exit(){
	$("#exitDiv").dialog({
		buttons: {
			"Выход": function(){
				$('#okExit').trigger('click');
        	},
			"Отмена": function(){
				$(this).dialog("close")
			}
		},
		modal: true,
		draggable : false
	}).dialog("open");

}
